package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.DzDongtai;
import com.ruoyi.system.service.IDzDongtaiService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 实时动态Controller
 * 
 * @author ruoyi
 * @date 2023-08-16
 */
@RestController
@RequestMapping("/system/dongtai")
public class DzDongtaiController extends BaseController
{
    @Autowired
    private IDzDongtaiService dzDongtaiService;

    /**
     * 查询实时动态列表
     */
    @GetMapping("/list")
    public TableDataInfo list(DzDongtai dzDongtai)
    {
        startPage();
        List<DzDongtai> list = dzDongtaiService.selectDzDongtaiList(dzDongtai);
        return getDataTable(list);
    }

    /**
     * 导出实时动态列表
     */
    @Log(title = "实时动态", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DzDongtai dzDongtai)
    {
        List<DzDongtai> list = dzDongtaiService.selectDzDongtaiList(dzDongtai);
        ExcelUtil<DzDongtai> util = new ExcelUtil<DzDongtai>(DzDongtai.class);
        util.exportExcel(response, list, "实时动态数据");
    }

    /**
     * 获取实时动态详细信息
     */
    @GetMapping(value = "/{ssId}")
    public AjaxResult getInfo(@PathVariable("ssId") Long ssId)
    {
        return AjaxResult.success(dzDongtaiService.selectDzDongtaiBySsId(ssId));
    }

    /**
     * 新增实时动态
     */
    @Log(title = "实时动态", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DzDongtai dzDongtai)
    {
        return toAjax(dzDongtaiService.insertDzDongtai(dzDongtai));
    }

    /**
     * 修改实时动态
     */
    @Log(title = "实时动态", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DzDongtai dzDongtai)
    {
        return toAjax(dzDongtaiService.updateDzDongtai(dzDongtai));
    }

    /**
     * 删除实时动态
     */
    @Log(title = "实时动态", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ssIds}")
    public AjaxResult remove(@PathVariable Long[] ssIds)
    {
        return toAjax(dzDongtaiService.deleteDzDongtaiBySsIds(ssIds));
    }
}
